﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Epona.Domain.Query;

namespace Epona.Domain
{
    public interface IRepository
    {
        T Save<T>(T entity) where T : IEntity;
        void Remove(IEntity entity);
        bool Exists<T>(int id) where T:IEntity;
        T Get<T>(int id) where T:IEntity;
        T Load<T>(int id) where T : IEntity;
        T GetUnmodified<T>(T entity) where T : IEntity;
        IList<T> FindAll<T>() where T : IEntity;
        CriteriaQuery CreateCriteriaQuery<T>() where T : IEntity;
        IList<T> Find<T>(CriteriaQuery criteriaQuery) where T : IEntity;
        T GetSingleResult<T>(CriteriaQuery criteriaQuery) where T : IEntity;
        //TODO
        //HqlQuery CreateHqlQuery(string hql);
        //IList<T> Find<T>(HqlQuery hqlQuery) where T : IEntity;
        //T GetSingleResult<T>(HqlQuery hqlQuery) where T : IEntity;
        //int ExecuteUpdate(HqlQuery hqlQuery);
        //NamedQuery CreateNamedQuery(string queryName);
        //IList<T> Find<T>(NamedQuery namedQuery) where T:IEntity;
        //T GetSingleResult<T>(NamedQuery namedQuery)where T:IEntity;
        //int ExecuteUpdate(NamedQuery namedQuery);
        //SqlQuery CreateSqlQuery(string sql);
        //IList<T> Find<T>(SqlQuery sqlQuery)where T:IEntity;
        //T GetSingleResult<T>(SqlQuery sqlQuery)where T:IEntity;
        //int ExecuteUpdate(SqlQuery sqlQuery);
        IList<T> FindByProperty<T>(string propertyName, object propertyValue) where T : IEntity;
        IList<T> FindByProperties<T>(NamedParameters properties) where T : IEntity;
        string GetQueryStringOfNamedQuery(string queryName);
        void Flush();
        void Refresh(IEntity entity);
        void Clear();

    }
}
